# -*- coding: utf-8 -*-
"""
Created on 03 08 下午4:55 2022 
@Author : HHQUAN
@Email : 1075960398@qq.com

"""

import mpl_toolkits.axisartist as axisartist
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = axisartist.Subplot(fig, 1,1,1)
fig.add_axes(ax)

ax.axis["right"].set_visible(False)
ax.axis["top"].set_visible(False)
ax.axis["left"].set_visible(False)
ax.axis["bottom"].set_visible(False)

ax.axis["x1"] = ax.new_fixed_axis(loc="top", offset=(0, -100)) # 前面一个数字左右，后面一个数字上下
ax.axis["x1"].set_axisline_style("->", size = 2.0)
ax.axis["x1"].major_ticklabels.set_color("b")
ax.axis["x1"].label.set_text(r"$\theta = 60^{\circ}$")

ax.axis["x2"] = ax.new_fixed_axis(loc="bottom", offset=(0, 60)) # 第二个数字往上都是正，往下都是负
ax.axis["x2"].set_axisline_style("->", size = 2.0)
ax.axis["x2"].major_ticklabels.set_color("r")

ax.axis["y1"] = ax.new_fixed_axis(loc="left", offset=(0, 0))
ax.axis["y1"].set_axisline_style("->", size = 2.0)
ax.axis["y1"].major_ticklabels.set_color("m")

# ax.set_xticks([-1.0, -0.5, 0, 0.5, 1])
# ax.set_xticklabels([r"$\frac{\pi}{4}$", r"$\frac{2\pi}{4}$", r"$\frac{3\pi}{4}$",
#                     r"$\frac{4\pi}{4}$",r"$\frac{5\pi}{4}$"])
# ax.set_yticks([-1.0, -0.5, 0.5, 1])
ax.axis["x1"].major_ticklabels.set_visible(True)
ax.axis["x2"].major_ticklabels.set_visible(True)
ax.axis["y1"].major_ticklabels.set_visible(False)

# 直线的画法
x = np.linspace(-0.5, 1., 20)
# color='green', marker='o', linestyle='dashed',linewidth=2, markersize=12
# ax.plot(x, np.sin(x*np.pi))
ax.stem(x, np.sin(x*np.pi), linefmt="-", markerfmt='.', basefmt=':b', bottom=0, label='y-axis')

ax.grid(True, linestyle='--', color='gray', linewidth=0.8)
plt.show()

